package com.chris.design.pattern.samples.observer;

public class ConcreteSubject extends AbstractSubject {

    private String state;

    public String getState() {
        return state;
    }

    @Override
    public void change(String newState, PushOrPullEnum type) {
        this.state = newState;
        System.out.println("主题状态为:" + state);
        switch (type) {
            case pull:
                // 拉模式
                this.notifyObservers();
                break;
            case push:
                // 状态发生改变，通知各个观察者。推模式
                this.notifyObservers(state);
                break;
            default:
                // do nothing
                break;
        }
    }
}
